package org.liangliang.iching;


import java.util.Collection;
import java.util.List;
import java.util.Map;
import java.util.function.Function;
import java.util.stream.Collectors;

public class MapUtils {

    public static <K, V> Map<K, V> cteateIndexMap(Collection<V> values, Function<V, K> keyFunction) {
        return values.stream().collect(Collectors.toMap(keyFunction,v -> v));
    }

    public static <K, V> Map<K, List<V>> cteategroupMap(Collection<V> values, Function<V, K> keyFunction) {
        return values.stream().collect(Collectors.groupingBy(keyFunction));
    }

    public static void main(String[] args) {

    }

}
